<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>优惠券领取</title>
    <link rel="stylesheet" type="text/css" href="__STATIC__/aui/aui.css" />
	<style>
		html,body{height: 100%;background: url(http://cdn.image.molbait.com/d624a05140951311779d568b69d07247.png);background-size: 100% 100%;}
  .info{
    position: fixed;bottom: 3rem;left:0;width: 100%;
  }
  .lgbtn{
    line-height: 2.45rem;
    height: 2.65rem;
    text-align: center;
    background: url(http://img.zhengouduo.com/new-reg.png) no-repeat;
    background-size: contain;
    width: 80%;
    color: #c54a00;
    margin: 0 auto;
    font-weight: bold;
  }
  .dialog-box .ipt-box {
    width: 80%;
    margin: 0 auto 0.5rem auto;
    overflow: hidden;
  }
  .dialog-box .ipt-row {
    background: #ffffff;
    border-radius: 1rem;
    display: flex;
    display: -webkit-box;
    align-items: center;
    -webkit-box-align: center;
    height: 2.425rem;
  }
  .dialog-box .ipt-row .input input {
    outline: none;
    border: none;
    line-height: 1.225rem;
    padding: 0.6rem 0;
    margin: 0;
    display: block;
    width: 80%;
    text-indent: 0.6rem;font-size: 0.7rem;
  }
  .ipt-box .aui-list-item-label-icon{
    display: inline-block;width: 0.85rem;
    height: 0.85rem;
    margin-left: 0.8rem;
  }
  .dialog-box .ipt-row.msgcode {
    width: 55%;
    float: left;
  }
  .dialog-box .ipt-box .getcode {
    background: #fddf1c;
    color: #c54a00;
    float: right;
    width: 40%;
    line-height: 2.425rem;
    text-align: center;
    font-size: 0.7rem;
    border-radius: 1rem;
  }
  .hide{
    display: none;
  }
  </style>
<!-- Bytedance Tracking -->
<script>
  (function(r,d,s,l){var meteor=r.meteor=r.meteor||[];meteor.methods=["track","off","on"];meteor.factory=function(method){return function(){
  var args=Array.prototype.slice.call(arguments);args.unshift(method);meteor.push(args);return meteor}};for(var i=0;i<meteor.methods.length;i++){
  var key=meteor.methods[i];meteor[key]=meteor.factory(key)}meteor.load=function(){var js,fjs=d.getElementsByTagName(s)[0];js=d.createElement(s);
  js.src="https://analytics.snssdk.com/meteor.js/v1/"+l+"/sdk";fjs.parentNode.insertBefore(js,fjs)};meteor.load();if(meteor.invoked){return}
  meteor.invoked=true;meteor.track("pageview")})(window,document,"script","2361373597893091");
</script>
<!-- End Bytedance Tracking -->
</head>
<body>
  <section class="aui-content aui-margin-t-15 aui-padded-15 info dialog-box">
    <div class="ipt-box">
			<div class="ipt-row">
        <div class="aui-list-item-label-icon">
            <i class="aui-iconfont aui-icon-mobile"></i>
        </div>
				<div class="input">
					<input type="tel" placeholder="请输入手机号码" id="mobile">
				</div>
			</div>
		</div>
		<div class="ipt-box">
			<div class="ipt-row msgcode">
        <div class="aui-list-item-label-icon">
          <i class="aui-iconfont aui-icon-cert"></i>
        </div>
				<div class="input">
					<input type="tel" placeholder="请输入验证码" id="smscode" maxlength="4">
				</div>
			</div>
			<!-- <div class="getcode">获取验证码</div> -->
      <div class="getcode codebtn1" id="getcode" onclick="SendSms(this)">获取验证码</div>
      <div class="getcode codebtn2 hide" id="codejqs">计时器</div>
		</div>
		<input type="hidden" name="code" value="{$code}" id="code">
    <div class="aui-btn aui-btn-block lgbtn" tapmode onclick="Submit(this)" >立即领取</div>
  </section>
</body>
<script src="https://cdn.bootcss.com/jquery/2.2.2/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/layer/2.3/layer.js"></script>
<script type="text/javascript">
//提交
function Submit(){
  var mobile = $('#mobile').val();
  var regex_mobile = /^((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8}$/;
  if (!regex_mobile.test(mobile)) {
    layer.msg('请输入正确的手机号');
    return false;
  }
  var vcode = $('#smscode').val();
  if (vcode=='') {
    layer.msg('请输入短信验证码');
    return false;
  }
  var code = $('#code').val();

  $.post('{:url('do_invite')}',{mobile: mobile,code:code,vcode:vcode}, function (ret) {
    layer.msg(ret.msg);
    meteor.track('form', {convert_id: 1630243879913486 })
    if (ret.code==1) {
      location.href = ret.url;
    }else if(ret.code==2){
      location.href = ret.data.downurl;
    }else{

    }
  });
}
//获取验证码
function SendSms(){
  var mobile = $('#mobile').val();
  var regex_mobile = /^((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8}$/;
  if (!regex_mobile.test(mobile)) {
    layer.msg('请输入正确的手机号');
    return false;
  }
  $.post('{:url('sendsms')}',{mobile: mobile}, function (ret) {
    layer.msg(ret.msg);
    if (ret.code==1) {
      //location.href = ret.url;
      showtime(120);
    }else if(ret.code==2){
      location.href = ret.data.downurl;
    }else{

    }
  });

}
//.计时器
function showtime(t) {
  for ( i = 1; i <= t; i++)
  {
    window.setTimeout("update(" + i + "," + t + ")", i * 1000);
  }
}
function update(num, t) {
  if (num == t) {
    $('.codebtn2').hide();
    $('.codebtn1').show();
    $('#getcode').text('重新获取');
  }
  else
  {
    printnr = t - num;
    $('.codebtn1').hide();
    $('.codebtn2').show();
    $('#codejqs').text('('+printnr + " 's)");
  }
}

</script>
</html>
